<template>
  <div>
    <div class="xinwenguanlis">
      <!-- 置顶的 -->
      <!-- 头 -->
      <div class="xinwenzhiding" v-show="showtou">
        <div @click="xadds">
          <span>新增新闻</span>
        </div>
        <div>
          <span>发布时间</span>
          <el-date-picker
            v-model="dStartTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="开始日期"
          ></el-date-picker
          >-
          <el-date-picker
            v-model="dEndTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="结束日期"
          ></el-date-picker>
        </div>
        <div>
          <span>公文等级</span>
          <!-- 标记 -->
          <el-select v-model="nGid">
            <el-option label="特急" value="1"></el-option>
            <el-option label="加急" value="2"></el-option>
            <el-option label="平急" value="3"></el-option>
          </el-select>
        </div>
        <div>
          <span>新闻类别</span>
          <el-select v-model="nTid">
            <el-option
              v-for="item in AllnewstypesEmpty"
              :key="item.nTid"
              :label="item.nNewsType"
              :value="item.nTid"
            ></el-option>
          </el-select>
        </div>
        <div>
          <input
            @blur="getData"
            class="danweimingc"
            type="text"
            v-model="sContent"
            placeholder="标题/内容摘要"
          />
          <el-button type="primary" @click="GetAllnews">查询</el-button>
        </div>
      </div>
      <!-- 内容 -->
      <div class="navs" v-show="showneirong">
        <thead></thead>

        <el-table
          :data="
            Allnews.slice((currentPage - 1) * pageSize, currentPage * pageSize)
          "
          tooltip-effect="dark"
          style="width: 100%"
          @select="tabid(nUid)"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            prop="sTitle"
            label="标题"
            width="140px"
            align="center"
          ></el-table-column>
          <el-table-column label width="50px" align="center">
            <template slot-scope="scope">
              <!-- 标记 -->
              <span v-if="scope.row.nTop == 1">置顶</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="nNewsType"
            label="新闻类别"
            width="140px"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="sContent"
            label="文章内容"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="sGrade"
            label="公文等级"
            width="169px"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="sCuName"
            label="编写人"
            width="140px"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="sSuName"
            label="审核人"
            width="140px"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="dSendTime"
            label="发布日期"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            prop="sContentType"
            label="附件"
            show-overflow-tooltip
            align="center"
          ></el-table-column>
          <el-table-column
            width="169px"
            label="操作"
            show-overflow-tooltip
            align="center"
          >
            <template slot-scope="scope">
              <!-- 标记 -->
              <button v-if="scope.row.nTop == 0" @click="changeTop1(scope.row)">
                置顶
              </button>
              <button v-if="scope.row.nTop == 1" @click="changeTop0(scope.row)">
                取消置顶
              </button>
              |
              <button @click="set(scope.row)">编辑</button>
              |
              <button href="#" @click.prevent="del(item.id)">删除</button>
            </template>
          </el-table-column>
        </el-table>
        <div>
          <!-- 分页 -->
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-size="pageSize"
            background
            layout="total, prev, pager, next"
            :total="Allnews.length"
          ></el-pagination>
        </div>
      </div>

      <!-- 置顶的 -->
      <div class="yulan_left" v-show="yulanshow">
        <div>{{ formLabelAlign.name }}</div>
        <div>
          <div>
            来源:
            <span>{{ formLabelAlign.newsly }}</span>
          </div>
          <div>
            发布时间:
            <span>虚拟</span>
          </div>
          <div>
            发布人:
            <span>{{ formLabelAlign.region6 }}</span>
          </div>
          <div>
            审核人:
            <span>{{ formLabelAlign.region4 }}</span>
          </div>
          <div>
            浏览量:
            <span>999+</span>
          </div>
          <div>打印</div>
        </div>
        <!-- 新闻 -->
        <div class="yulan-xinwen">{{ formLabelAlign.newsnr }}</div>
        <!-- 附件 -->
        <div class="fujian_yulan"></div>
        <div class="fanhui_yulan" @click="fanhui_yulan">
          <button>返回</button>
        </div>
      </div>
      <div class="mod4 flex-col" v-show="showxinzeng">
        <!-- 头部 -->
        <div class="first">
          <el-button
            type="info"
            @click="wenzhangxw"
            :class="operateValue === 'wz' ? 'anniu1' : 'anniu2'"
            >文章新闻</el-button
          >
          <el-button
            type="info"
            @click="shipin"
            :class="operateValue === 'sp' ? 'anniu1' : 'anniu2'"
            >视频新闻</el-button
          >
        </div>
        <!-- /头部 -->

        <!-- 身体 -->
        <div class="container">
          <div class="container_left">
            <el-form
              :label-position="labelPosition"
              label-width="140px"
              :model="formLabelAlign"
            >
              <el-form-item label="文章标题">
                <el-input v-model="formLabelAlign.name"></el-input>
                <el-checkbox class="zd" v-model="checked">置顶</el-checkbox>
              </el-form-item>
              <el-form-item label="显示区域" class="xianshi">
                <el-select
                  v-model="formLabelAlign.region1"
                  placeholder="请选择显示区域"
                >
                  <el-option label="仅在新闻类别显示" value="1"></el-option>
                  <el-option label="仅在公安头条显示" value="2"></el-option>
                  <el-option
                    label="新闻类别和轮播图都显示"
                    value="3"
                  ></el-option>
                  <el-option label="仅在轮播图显示" value="4"></el-option>
                </el-select>
              </el-form-item>
              <!-- 选择新闻类别显示内容 -->
              <div
                v-if="
                  formLabelAlign.region1 == '3' || formLabelAlign.region1 == '4'
                "
                class="lunbo-xianshi"
              >
                <el-form-item label="封面图">
                  <!-- 添加照片 -->
                  <el-upload
                    v-if="formLabelAlign.region4 !== '4'"
                    action="https://jsonplaceholder.typicode.com/posts/"
                    list-type="picture-card"
                    :on-preview="handlePictureCardPreview"
                    :on-remove="handleRemove"
                  >
                    <i class="el-icon-plus"></i>
                  </el-upload>
                  <el-dialog :visible.sync="dialogVisible">
                    <img width="100%" :src="dialogImageUrl" alt />
                  </el-dialog>
                </el-form-item>
                <div
                  class="tishi"
                  v-show="(formLabelAlign.region1 == '4') == false"
                >
                  <!-- 轮播图: 建议尺寸：
                  <span>305*210</span>，支持png、jpg、jpeg格式-->
                </div>
              </div>
              <!-- 公安头条显示内容 -->
              <el-form-item class="leibie" label="新闻类别">
                <el-select
                  v-model="formLabelAlign.region2"
                  placeholder="请选择新闻类别"
                >
                  <el-option
                    v-for="item in AllnewstypesEmpty"
                    :key="item.nTid"
                    :label="item.nNewsType"
                    :value="item.nTid"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="公文等级" class="gongwen">
                <el-select
                  v-model="formLabelAlign.region3"
                  placeholder="请选择公文等级"
                >
                  <el-option label="特急" value="1"></el-option>
                  <el-option label="加急" value="2"></el-option>
                  <el-option label="平急" value="3"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="审核人">
                <el-select
                  class="shenheren"
                  @change="AlluserBynOid"
                  v-model="formLabelAlign.region4"
                  placeholder="请选择单位"
                >
                  <el-option
                    v-for="item in Allorganizations"
                    :key="item.nUid"
                    :label="item.sName"
                    :value="item.nOid"
                  ></el-option>
                </el-select>
                <el-select
                  class="renyuan1"
                  v-model="formLabelAlign.region5"
                  @change="nuidnews"
                  placeholder="请选择人员"
                >
                  <el-option
                    v-for="item in newsAlluserBynOid"
                    :key="item.nUid"
                    :label="item.sName"
                    :value="item.nUid"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="编写人">
                <el-select
                  class="bianxieren"
                  v-model="formLabelAlign.region6"
                  placeholder="请选择编写人"
                >
                  <el-option :label="newsname" :value="nOids"></el-option>
                </el-select>
                <el-select
                  class="renyuan2"
                  v-model="formLabelAlign.region7"
                  placeholder="请选择人员"
                >
                  <el-option :label="newsname" :value="nUids"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="来源">
                <el-input v-model="formLabelAlign.newsly"></el-input>
              </el-form-item>
              <el-form-item label="审核">
                <!-- <el-checkbox v-model="checked1">审核通过</el-checkbox>
                <el-checkbox v-model="checked2">审核未通过</el-checkbox> -->
               <template>
                  <el-radio v-model="checked1" label="1">审核通过</el-radio>
                  <el-radio v-model="checked1" label="2">审核未通过</el-radio>
               </template>
              </el-form-item>
              <el-form-item label="附件" v-show="isFujian">
                <el-upload
                  :on-success="handleyes"
                  :on-preview="handlePreview"
                  class="upload-demo"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :on-change="handleChange"
                  :file-list="fileList"
                >
                  <div class="shangchuan">
                    <span>+添加附件</span>
                  </div>
                </el-upload>
              </el-form-item>
              <el-form-item label="上传视频" v-show="isShipin">
                <el-upload
                  class="upload-demo"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :on-change="handleChange"
                  :file-list="fileList"
                >
                  <div class="shangchuan">
                    <span>+上传视频</span>
                  </div>
                </el-upload>
              </el-form-item>
              <el-form-item label="文章内容" prop="desc" class="hdxs1">
                <textarea
                  v-model="formLabelAlign.newsnr"
                  name
                  id
                  cols="30"
                  rows="10"
                  class="hdxs"
                ></textarea>
              </el-form-item>
            </el-form>
            <div class="footer">
              <el-button @click="Addnews" type="primary" class="fabu"
                >发布</el-button
              >
              <el-button type="info" @click="yulanClick" plain class="yulan"
                >预览</el-button
              >
              <el-button type="info" plain class="fanhui" @click="fanhuiss"
                >返回</el-button
              >
            </div>
          </div>
          <div class="container_right">
            <!-- 上 -->
            <div class="container_right_top">
              <span class="cover">接收单位</span>
            </div>
            <!-- /上 -->
            <!-- 中 -->
            <div class="container_right_body">
              <div class="box">
                <el-table
                  ref="multipleTable"
                  :data="Allorganizations"
                  tooltip-effect="dark"
                  @select="newsid"
                  style="width: 100%"
                  @selection-change="handleSelectionChange"
                >
                  <el-table-column
                    type="selection"
                    width="55"
                  ></el-table-column>
                  <el-table-column prop="sName" label="全选" width="120">
                    <template slot-scope="scope">{{
                      scope.row.sName
                    }}</template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
            <!-- /中 -->
            <!-- 下 -->
            <!-- /下 -->
          </div>
        </div>
        <!-- /身体 -->
      </div>
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
export default {
  data() {
    return {
      PostSelectNewsEmpty: [],
      AllnewstypesEmpty: [],
      // 日期
      dStartTime: "",
      dEndTime: "",
      nTid: "",
      nGid: "",
      sContent: "",
      ids: 0,
      isShipin: false,
      isFujian: true,
      operateValue: "wz",
      fileList: [
        {
          name: "food.jpeg",
          url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
        {
          name: "food2.jpeg",
          url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
      ],

      // 获取单位的数据
      Allorganizations: [],
      // 所有新闻
      Allnews: [],
      // 表格
      xinwenleibie: "",
      pid: "",
      list: [],
      // 每页数据条数
      pageSize: 10,
      currentPage: 1,
      total: 20,
      biaoti: "",
      xinwen: "",
      wenzhang: "",
      dengji: "",
      bianxi: "",
      shenhe: "",
      riqi: "",
      fujian: "",
      newlist: [
        {
          biaoti: "",
          xinwen: "",
          wenzhang: "",
          dengji: "",
          bianxi: "",
          shenhe: "",
          riqi: "",
          fujian: "",
        },
      ],
      selected: [
        { id: 1, name: "平级" },
        { id: 2, name: "高级" },
      ],
      keywords: "",
      // 分页
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.currentPage = 1;
        // this.pageSize = val;
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        // this.currentPage = val;
      },
      // 日期

      // 上传照片
      dialogImageUrl: "",
      dialogVisible: false,
      fileList: [],
      constants: {},
      labelPosition: "right",
      formLabelAlign: {
        newsly: "",
        newsnr: "",
        name: "",
        region1: null,
        region2: null,
        region3: null,
        region4: null,
        region5: null,
        region6: null,
        region7: null,
        type: "",
        fujianname: "",
      },
      checked: true,
      region1: "",
      region2: "",
      region3: "",
      region4: "",
      region5: "",
      region6: "",
      region7: "",
      yulanshow: false,
      checked1: true,
      checked2: false,
      showxinzeng: false,
      showneirong: true,
      showtou: true,
      desc: "",
      // 用户id
      nUids: [],
      // 单位id
      nOids: [],
      // 登录人
      newsname: [],
      // 单位对应的人
      newsdwID: [],
      // 单位id 拼接
      nOidList: [],
      // 新增新闻成功时的主键id
      keysid: 0,
      newsAlluserBynOid: [],
      Allorganizations: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
    };
  },
  created() {
    this.GetAllnews();
    this.GetAllorganizations();
    this.Allnewstypes();
  },
  methods: {
    // 获取单位对应的人员
    async AlluserBynOid(id) {
      console.log(id);
      const { data: res } = await this.$http.get(
        "/api/user/Get_AlluserBynOid",
        {
          params: {
            innOid: id,
          },
        }
      );
      console.log(res);
      this.newsAlluserBynOid = res;
    },
    //标记
    // 获取所有新闻
    async GetAllnews() {
      this.newsname = Cookies.get("username");
      this.nUids = Cookies.get("nUid");
      this.nOids = Cookies.get("nOid");
      let formData = new FormData();
      formData.append("dStartTime", this.dStartTime);
      formData.append("dEndTime", this.dEndTime);
      formData.append("nGid", this.nGid);
      formData.append("nTid", this.nTid);
      formData.append("sContent", this.sContent);

      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      const { data: res } = await this.$http.post(
        "/api/news/Post_Allnews",
        formData,
        config
      );
      res.sort(this.topSort);
      this.Allnews = res;
      this.dStartTime=''
      this.dEndTime=''
      this.nGid=''
      this.nTid=''
      this.sContent=''
    },

    // 接口 获取所有单位
    async GetAllorganizations() {
      const { data: res } = await this.$http.get(
        "/api/organization/Get_Allorganizations"
      );
      this.Allorganizations = res;
    },
    //获取所有新闻类别内容
    async Allnewstypes() {
      const { data: res } = await this.$http.get(
        "/api/newstype/Get_Allnewstypes",
        {
          params: {
            nState: 1,
          },
        }
      );
      this.AllnewstypesEmpty = res;
      console.log(res);
    },
    // 新增新闻
    async Addnews() {
      let a, b;
      //  a是否置顶
      if (this.checked == true) {
        a = 1;
      } else {
        a = 0;
      }
      if (this.checked1 == true) {
        b = 1;
      }
      if (this.checked2 == true && this.checked1 == false) {
        b = 0;
      }
      // 获取当前时间 datetime
      let d = new Date();
      let month =
        d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
      let day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
      let hours = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
      let min = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
      let sec = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
      let timedate =
        d.getFullYear() +
        "-" +
        month +
        "-" +
        day +
        " " +
        hours +
        ":" +
        min +
        ":" +
        sec;
      console.log(timedate);

      let formData = new FormData();
      // 标题
      formData.append("sTitle", this.formLabelAlign.name);
      // 审核人id
      formData.append("nSuid", this.ids);
      // 编写人id
      formData.append("nBuid", this.nUids);
      // 是否审核    1已审核；0未审核
      formData.append("nExamine", b);
      // 内容
      formData.append("sContent", this.formLabelAlign.newsnr);
      // 发布时间
      formData.append("dSendTime", timedate);
      // 浏览量
      formData.append("nNum", 999);
      // 是否置顶     1已置顶；0未置顶
      formData.append("nTop", a);
      // 插图编号
      formData.append("nPictureNum", 4);
      // 等级编号
      formData.append("nGid", this.formLabelAlign.region3);
      // 类型编号
      formData.append("nTid", this.formLabelAlign.region2);
      // 区域编号
      formData.append("nDid", this.formLabelAlign.region1);
      // 附件类型
      formData.append("insContentType", this.formLabelAlign.fujianname);
      // 附件内容
      formData.append("insConUrl", "附件内容");

      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      // this.NewsAddnewscontent()
      // 添加新闻
      const { data: res } = await this.$http.post(
        "/api/news/Post_Addnews",
        formData,
        config
      );
      console.log(res);
      this.keysid = res;
      let adnew = {
        sTitle: this.formLabelAlign.name,
        nSuid: this.ids,
        nBuid: this.formLabelAlign.region6,
        nExamine: b,
        sContent: this.formLabelAlign.newsnr,
        dSendTime: timedate,
        nNum: 999,
        nTop: a,
        nPictureNum: 4,
        nGid: this.formLabelAlign.region3,
        nTid: this.formLabelAlign.region2,
        nDid: this.formLabelAlign.region1,
        insContentType: this.formLabelAlign.fujianname,
        insConUrl: "附件内容",
      };
      this.Allnews.push(adnew);
      this.GetAllnews();
      this.showneirong = true;
      this.showxinzeng = false;
      this.showtou = true;
      this.Addnewsreceiveorg();
    },
    // 修改新闻
    async Addnews() {
      let a, b;
      //  a是否置顶
      if (this.checked == true) {
        a = 1;
      } else {
        a = 0;
      }
      if (this.checked1 == true) {
        b = 1;
      }
      if (this.checked2 == true && this.checked1 == false) {
        b = 0;
      }
      // 获取当前时间 datetime
      let d = new Date();
      let month =
        d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
      let day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
      let hours = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
      let min = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
      let sec = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
      let timedate =
        d.getFullYear() +
        "-" +
        month +
        "-" +
        day +
        " " +
        hours +
        ":" +
        min +
        ":" +
        sec;
      console.log(timedate);

      let formData = new FormData();
      // 标题
      formData.append("sTitle", this.formLabelAlign.name);
      // 审核人id
      formData.append("nSuid", this.ids);
      // 编写人id
      formData.append("nBuid", this.nUids);
      // 是否审核    1已审核；0未审核
      formData.append("nExamine", b);
      // 内容
      formData.append("sContent", this.formLabelAlign.newsnr);
      // 发布时间
      formData.append("dSendTime", timedate);
      // 浏览量
      formData.append("nNum", 999);
      // 是否置顶     1已置顶；0未置顶
      formData.append("nTop", a);
      // 插图编号
      formData.append("nPictureNum", 4);
      // 等级编号
      formData.append("nGid", this.formLabelAlign.region3);
      // 类型编号
      formData.append("nTid", this.formLabelAlign.region2);
      // 区域编号
      formData.append("nDid", this.formLabelAlign.region1);
      // 附件类型
      formData.append("insContentType", this.formLabelAlign.fujianname);
      // 附件内容
      formData.append("insConUrl", "附件内容");

      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      // this.NewsAddnewscontent()
      // 添加新闻
      const { data: res } = await this.$http.post(
        "/api/news/Post_Updatenews",
        formData,
        config
      );
      console.log(res);
      this.keysid = res;
      let adnew = {
        sTitle: this.formLabelAlign.name,
        nSuid: this.ids,
        nBuid: this.formLabelAlign.region6,
        nExamine: b,
        sContent: this.formLabelAlign.newsnr,
        dSendTime: timedate,
        nNum: 999,
        nTop: a,
        nPictureNum: 4,
        nGid: this.formLabelAlign.region3,
        nTid: this.formLabelAlign.region2,
        nDid: this.formLabelAlign.region1,
        insContentType: this.formLabelAlign.fujianname,
        insConUrl: "附件内容",
      };
      this.Allnews.push(adnew);
      this.GetAllnews();
      this.showneirong = true;
      this.showxinzeng = false;
      this.showtou = true;
      this.Addnewsreceiveorg();
    },
    // 标记
    // 改变置顶状态
    async changeTop1(row) {
      this.nNewId = row.nNewId;
      let formData = new FormData();
      formData.append("nNewId", this.nNewId);
      formData.append("nTop", 1);
      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      const { data: res } = await this.$http.post(
        "/api/news/Post_UpdatenewsTop",
        formData,
        config
      );
      console.log(res);
       this.GetAllnews();
    },
    // 标记
    // 改变置顶状态
    async changeTop0(row) {
      this.nNewId = row.nNewId;
      let formData = new FormData();
      formData.append("nNewId", this.nNewId);
      formData.append("nTop", 0);
      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      const { data: res } = await this.$http.post(
        "/api/news/Post_UpdatenewsTop",
        formData,
        config
      );
      console.log(res);
       this.GetAllnews();
    },


    // 获取单位id
    newsid(row) {
      // console.log(row);
      this.newsdwID = row;
      for (let i = 0; i < this.newsdwID.length; i++) {
        this.nOidList.push(this.newsdwID[i].nOid);
      }
      // 数组去重
      [...new Set(this.nOidList)];
      console.log([...new Set(this.nOidList)].join(","));
    },
    async Addnewsreceiveorg() {
      let formData = new FormData();
      // 部门拼接id
      formData.append("sOidList", [...new Set(this.nOidList)].join(","));
      // 所属新闻id
      formData.append("nNid", this.keysid);

      const config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      // 添加新闻
      const { data: res } = await this.$http.post(
        "/api/newsreceiveorg/Post_Addnewsreceiveorg",
        formData,
        config
      );
      console.log(res);
    },
    // 添加附件

    yulanClick() {
      this.yulanshow = true;
      this.showxinzeng = false;
    },
    fanhui_yulan() {
      this.yulanshow = false;
      this.showxinzeng = true;
    },
    wenzhangxw() {
      this.operateValue = "wz";
      this.isFujian = true;
      this.isShipin = false;
    },
    shipin() {
      this.operateValue = "sp";
      this.isShipin = true;
      this.isFujian = false;
    },

    search(keywords, pid, xinwenleibie) {
      let newList = this.list;
      newList = newList.filter((item) => {
        if (item.biaoti.includes(keywords)) {
          return item;
        }
      });
      newList = newList.filter((item) => {
        if (item.xinwen.includes("")) {
          return item;
        }
      });
      return newList;
    },
    getData() {
      //   const obj = [{ gongwen: this.pid, xinw: this.xinwenleibie, search: this.keywords }]
      //   console.log(obj);
    },
    // 新增按钮
    xadds() {
      this.showneirong = false;
      this.showxinzeng = true;
      this.showtou = false;
    },
    // 编辑按钮
    set(row) {
      this.showneirong = false;
      this.showxinzeng = true;
      this.showtou = false;
      this.sTitle = row.sTitle;
      this.nSuid = row.nSuid;
      this.nBuid = row.nBuid;
      this.nExamine = row.nExamine;
      // 内容
      this.formLabelAlign.newsnr = row.sContent;
      this.nTop = row.nTop;
      // 等级编号
      this.formLabelAlign.region3 = row.formLabelAlign.region3;
      // 类型编号
      this.formLabelAlign.region2 = row.formLabelAlign.region2;
      this.nDid = row.nDid;
    },
    // 标记
    topSort(a, b) {
      return Number(b.nTop) - Number(a.nTop);
    },
    fanhuiss() {
      this.showneirong = true;
      this.showxinzeng = false;
      this.showtou = true;
    },
    handleChange(file, fileList) {
      this.fileList = fileList.slice(-3);
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 上传照片
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    // 人员id
    nuidnews(ids) {
      this.ids = ids;
    },
    handleyes(file, fileList) {
      this.formLabelAlign.fujianname = fileList.name;
      console.log(fileList.name);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>
<style scoped lang="css" src="./assets/index.css" />
